home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9557 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  56 lines

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.sources.wanted,comp.lang.c,comp.unix.programmer
  4. Subject: Re: Seek unix2dos.c OR help with tr
  5. Date: 10 Mar 1996 22:43 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <10MAR199622434233@erich.triumf.ca>
  9. References: <4i0946$7io@nuke.csu.net>
  10. NNTP-Posting-Host: ftp.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <4i0946$7io@nuke.csu.net>, mclean@futon.SFSU.EDU (Emmett Mclean) writes...
  14. >Hi,
  15. >Does anyone have the source to a program
  16. >converting a unix file into dos format?
  17. >That is, each decimal 10 char is replaced
  18. >with a series of a 10 and 13.
  19. >The equivalent syntax to tr would be fine
  20. >as well.
  21. >I will be using it to download zipped binaries
  22. >files from a unix box.
  23.  
  24. If you are transferring zipped (or other binary) files, you DO NOT want to
  25. change 0x10 to 0x10,0x13!!  doing so will corrupt any binary file.
  26.  
  27. This conversion is _only_ required for text files.
  28.  
  29. >#include <stdio.h>
  30. >main(){
  31. >char c;
  32. >while(EOF!=(c=getchar())){
  33. > if(10==c)putchar(13);
  34.  
  35. You should declare c as int, not char, since getchar() returns an int, and EOF
  36. is a negative int, outside the range that can be represented by a char.
  37.  
  38. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  39. Internet: bennett@triumf.ca         | of one another only when one can be
  40. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  41. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  42. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  43. or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.